home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / print / p1123mz4.zip / SQRMAZE.H < prev    next >
C/C++ Source or Header  |  1994-02-14  |  3KB  |  103 lines

  1. #ifndef SQRMAZE_H
  2. #define SQRMAZE_H
  3.  
  4. //      Each instance of this class is a maze having square rooms.
  5.  
  6. //      This class uses the classes "cell" (room of a maze), "oracle"
  7. // (random number generator), and "titillat" (amuse user).
  8.  
  9. class maze
  10.   {
  11.     private:
  12.       oracle     *column_selector;
  13. //      Random number generator to select column to start constructing maze.
  14.  
  15.       struct
  16.         {
  17.            int row_num;
  18.            int column_num;
  19.         }        current;
  20. //      Current location in maze.
  21.  
  22.       int        memory_allocated;
  23. //      The two dimensional array of rooms has been allocated.
  24.  
  25.       int        num_columns;
  26. //      Number of columns in maze.
  27.  
  28.       int        num_rows;
  29. //      Number of rows in maze.
  30.  
  31.       oracle     *order_selector;
  32. //      Random number generator to select the order walls are to considered.
  33.  
  34.       cell       **room;
  35. //      Two dimensional array of rooms composing the maze.
  36.  
  37.       oracle     *row_selector;
  38. //      Random number generator to select row to start constructing maze.
  39.  
  40.       titillator *titillator_ptr;
  41. //      Keep the user amused while the maze is constructed.
  42.  
  43.       struct
  44.         {
  45.            int row_num;
  46.            int column_num;
  47.         }        first;
  48. //      Location of the starting room.
  49.  
  50.       int        wall_thickness;
  51. //      Thickness of wall.
  52.  
  53.     public:
  54.  
  55.       int    constructed(void) {return memory_allocated;}
  56. //      Return TRUE if and only if the maze is successfully constructed.
  57.  
  58.       int    external_to_maze(double x,double y);
  59. //      Return TRUE if and only if a point (x,y) is external to the maze.
  60.  
  61.       double f(double x,double y);
  62. //      Return 6.0*wall_thickness if a point (x,y) is on a wall, 0.0 otherwise.
  63.  
  64.              maze(int row_count,int column_count,int thickness_of_wall,
  65.               char *seed);
  66. //      Contruct a maze having "row_count" rows and "column_count" columns of
  67. // rooms.  The walls should be "thickness_of_wall" (bricks) thick.  A different
  68. // (8 character of less) "seed" generally yields a different maze.
  69.  
  70.              ~maze(void);
  71.  
  72.       int    maze_okay(void);
  73. //      TRUE if and only if solving the maze is difficult enough.
  74.  
  75.       int    num_x_divisions(void)
  76.               {return 3*wall_thickness*num_rows+wall_thickness+2;}
  77. //      Recommended number of x divisions for plotting f(x,y).
  78.  
  79.       int    num_y_divisions(void)
  80.               {return 3*wall_thickness*num_columns+wall_thickness+2;}
  81. //      Recommended number of y divisions for plotting f(x,y).
  82.  
  83.       int    part_of_solution(double x,double y);
  84. //      Return TRUE if and only if a point (x,y) is on a wall outlining the
  85. // solution to the maze.
  86.  
  87.       double x_max(void)
  88.               {return double(3*wall_thickness*num_rows+wall_thickness);}
  89. //      Recommended maximum value of x for plotting f(x,y).
  90.  
  91.       double x_min(void) {return(-1.0);}
  92. //      Recommended minimum value of x for plotting f(x,y).
  93.  
  94.       double y_max(void)
  95.               {return double(3*wall_thickness*num_columns+wall_thickness);}
  96. //      Recommended maximum value of y for plotting f(x,y).
  97.  
  98.       double y_min(void) {return(-1.0);}
  99. //      Recommended minimum value of y for plotting f(x,y).
  100.   };
  101.  
  102. #endif
  103.